package com.lwl.controller.scl;


import com.github.pagehelper.PageInfo;
import com.lwl.entity.LayData;
import com.lwl.entity.MyPage;
import com.lwl.entity.scl.RecordMsg;
import com.lwl.entity.scl.StatisticsMsg;
import com.lwl.entity.scl.TSclRecord;
import com.lwl.service.scl.TSclRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * (TSclRecord)表控制层
 *
 * @author makejava
 * @since 2022-10-31 01:30:37
 */
@RestController
@RequestMapping("tSclRecord")
public class TSclRecordController {
    /**
     * 服务对象
     */
    @Autowired
    private TSclRecordService tSclRecordService;

    /*
        登录前检查手机号是否已经存在
     */
    @GetMapping("checkTel")
    public LayData checkTel(TSclRecord tSclRecord){
        System.out.println("tSclRecord = " + tSclRecord);
        Boolean i = tSclRecordService.checkTel(tSclRecord);
        return new LayData(i);
    }

    /*
        添加记录
     */
    @PostMapping("addRecord")
    public LayData addRecord(TSclRecord tSclRecord){
        int id = tSclRecordService.addRecord(tSclRecord);
        return new LayData(id);
    }

    /*
        查询所有的做题记录
     */
    @GetMapping("queryAll")
    public LayData queryAll(MyPage myPage, RecordMsg recordMsg){
        PageInfo pageInfo = tSclRecordService.queryAll(myPage,recordMsg);
        return new LayData(pageInfo);
    }

    /*
        根据id删除做题记录
     */
    @DeleteMapping("delRecord/{id}")
    public LayData delRecord(@PathVariable Integer id){
        Boolean i = tSclRecordService.delRecord(id);
        return new LayData(i);
    }

    /*
        查看详情
     */
    @GetMapping("{id}")
    public LayData queryDetails(@PathVariable Integer id,MyPage myPage){
        PageInfo pageInfo = tSclRecordService.queryDetails(myPage,id);
        return new LayData(pageInfo);
    }

    /*
        统计显示
     */
    @RequestMapping("statistics")
    public LayData statistics(MyPage myPage, StatisticsMsg statisticsMsg){
        PageInfo pageInfo = tSclRecordService.statistics(myPage,statisticsMsg);
        return new LayData(pageInfo);
    }
}
